/**
 * Created by geqq on 2018/5/14 0937.
 */
var OperateRecord = new Vue({
    el: '#operate-record',
    data: {
        datas: {
            'paginator':{},
            'recordList': []
        },
        recordInfo: {},
        isShowBindAccount: false,
        isShowVerification: false,
        isShowDetail: false,
        search: {
            pageNo: 1,
            pageSize: 20,
            startDate: '',
            endDate: ''
        }
    },
    methods: {
        getOperateRecord: function () {
            var _this = this;
            _this.setAjaxOptions('/getOperateRecord', _this.search, function (result, status, jqXHR) {
                if (result.retCode == 0) {
                    _this.datas = result.data;
                    Vue.useLayerPage('laypage', _this.datas.paginator, _this.search)
                } else {
                    console.log(result.errMsg);
                }
            });
            _this.doAjax();
        },
        showDetail: function (record) {
            if (!this.isShowDetail) {
                var _this = this;
                _this.setAjaxOptions('/getRecordInfo', {recordId: record.id}, function (result, status, jqXHR) {
                    if (result.retCode == 0) {
                        _this.recordInfo = result.data;
                        _this.recordInfo.operateType = record.operateType;
                        _this.recordInfo.roomName = record.roomName;
                    } else {
                        console.log(result.errMsg);
                    }
                });
                _this.doAjax();
                this.isShowDetail = !this.isShowDetail;
            }


            Vue.useLayerForm();
        },
        showBindAccount: function () {
            if (!this.isShowBindAccount) {
                this.isShowBindAccount = !this.isShowBindAccount;
            }

            Vue.useLayerForm();
        },
        showVerification: function () {
            if (!this.isShowVerification) {
                this.isShowVerification = !this.isShowVerification;
            }

            Vue.useLayerForm();
        }
    },
    mixins: [AjaxMixin, StatusMixin, UserMixin],
    mounted: function () {
        Vue.useLayerElement();
        this.search.startDate = moment().subtract(6, 'days').format('YYYY-MM-DD'); // 6天前
        this.search.endDate = moment().format('YYYY-MM-DD'); // 当前天
        Vue.useLayerDate(['startDate', 'endDate'], this.search);
        this.getOperateRecord();
    },
    watch: {
        search: {
            deep: true,
            handler: function (val, oldVal) {
                this.getOperateRecord();
            }
        }
    }
});